<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改项目')" />
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-project-edit" th:object="${tblProject}">
            <input name="id" th:field="*{id}" type="hidden">
            <input id="leader" name="leader" type="hidden" th:field="*{leader}" />
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">名称：</label>
                <div class="col-sm-8">
                    <input name="name" th:field="*{name}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">负责人：</label>
                <div class="col-sm-8">
                    <select id="leaderId" name="leaderId" class="form-control m-b" onchange="selectLeader(this)">
                        <option value="">--请选择--</option>
                        <option th:each="leaders:${leaders}" th:value="${leaders.userId}" th:text="${leaders.userName}" th:disabled="${leaders.status == '1'}" th:phone="${leaders.phonenumber}" th:email="${leaders.email}" th:field="*{leaderId}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">甲方：</label>
                <div class="col-sm-8">
                    <input id="buyers" name="buyers" th:field="*{buyers}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">乙方：</label>
                <div class="col-sm-8">
                    <input id="sellers" name="sellers" th:field="*{sellers}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">项目计划时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="startDate" th:value="${#dates.format(tblProject.startDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" style="float: left;width: 49%;">
                        <div style="float: left;width: 2%;">~</div>
                        <input name="endDate" th:value="${#dates.format(tblProject.endDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" style="float: left;width: 49%;">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control">[[*{remark}]]</textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('project_status')}">
                        <input type="radio" th:id="${'status_' + dict.dictCode}" name="status" th:value="${dict.dictValue}" th:field="*{status}">
                        <label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: select2-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "system/project";
        $("#form-project-edit").validate({
            focusCleanup: true
        });

        function  selectLeader(e){
            try {
                var opt = $(e.options[e.selectedIndex]);
                var leader = opt.text();
                if(!leader){
                    leader = ""
                }
                $('#leader').val(leader);
            }catch (e){

            }
        }

        $("input[name='startDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='endDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });


        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-project-edit').serialize());
            }
        }
    </script>
</body>
</html>